package com.bawei.module_home.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bawei.module_home.R

//class LooperAdapter {
//}


class LooperAdapter(private val mData: List<String>) :
    RecyclerView.Adapter<LooperAdapter.ViewHolder>() {

    // 添加当前可见位置变量
    var currentVisiblePosition = 0

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(parent.context)
            .inflate(R.layout.simple_list_item_1, parent, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val text = mData[position % mData.size]
        holder.textView.text = text
    }

    override fun getItemCount(): Int {
        return Int.MAX_VALUE
    }

    class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var textView: TextView = itemView.findViewById(R.id.text1)

        init {
            textView.textSize = 16f
            textView.setPadding(0, 16, 0, 16)
        }
    }
}